package com.mentor.mate.academy.gamebook;

import java.util.Random;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class FirstGameScreen extends Activity implements OnClickListener {

	private Button button1, button2, button3, button4;

	private int healthPoints[] = new int[] { 36, 16, 38, 19, 77, 45, 51, 100 };
	private int powerPoints[] = new int[] { 20, 30, 100, 44, 60, 50, 90, 70 };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.first_game_screen);

		initLayout();

	}

	private void initLayout() {
		button1 = (Button) findViewById(R.id.button1);
		button2 = (Button) findViewById(R.id.button2);
		button3 = (Button) findViewById(R.id.button3);
		button4 = (Button) findViewById(R.id.button4);

		button1.setOnClickListener(this);
		button2.setOnClickListener(this);
		button3.setOnClickListener(this);
		button4.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		int hp = 0;
		int pp = 0;
		Random rand = new Random();
		switch (v.getId()) {
		case R.id.button1:
			hp = healthPoints[rand.nextInt(healthPoints.length)];
			pp = powerPoints[rand.nextInt(powerPoints.length)];
			break;
		case R.id.button2:
			hp = healthPoints[rand.nextInt(healthPoints.length)];
			pp = powerPoints[rand.nextInt(powerPoints.length)];
			break;
		case R.id.button3:
			hp = healthPoints[rand.nextInt(healthPoints.length)];
			pp = powerPoints[rand.nextInt(powerPoints.length)];
			break;
		case R.id.button4:
			hp = healthPoints[rand.nextInt(healthPoints.length)];
			pp = powerPoints[rand.nextInt(powerPoints.length)];
			break;
		}
		Log.e("##" + this.getClass().toString(), "hp = " + hp);
		Log.e("##" + this.getClass().toString(), "pp = " + pp);

		Intent intent = new Intent(getApplicationContext(), FirstQuest.class);
		intent.putExtra("hp", hp);
		intent.putExtra("pp", pp);
		startActivity(intent);
	}
}
